package GUI.Test;

import java.awt.Color;
import java.awt.Font;
import java.awt.ScrollPane;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.BevelBorder;
import javax.swing.border.CompoundBorder;
import javax.swing.border.LineBorder;
import javax.swing.table.DefaultTableModel;

import Entity.Test;
import GUI.Course.CourseManage;
import GUI.Dog.DogManage;
import GUI.Report.ReportManage;

/**
 * 
 * this window display to the user  dog's test results.
 * 
 * **All communication with Database is thru Controller Sys.java
 *    
 *
 */

public class ShowDogResults extends JFrame {

	private static final long serialVersionUID = 1L;
		private JTable table;
		private ArrayList<Test> tests;
		private JTable table_1;
     	@SuppressWarnings("unused")
		public ShowDogResults(ArrayList<Test> testList1) {
     		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     	tests=testList1;
		setTitle("\u05E6\u05E4\u05D9\u05D9\u05D4 \u05D1\u05EA\u05D5\u05E6\u05D0\u05D5\u05EA \u05DE\u05D1\u05D7\u05DF \u05DC\u05DB\u05DC\u05D1");
		this.setSize(600, 500);
		
		JButton button_2 = new JButton("\u05E7\u05D5\u05E8\u05E1\u05D9\u05DD");
		button_2.setFont(new Font("David", Font.PLAIN, 14));
		button_2.setBackground(UIManager.getColor("Button.background"));
		button_2.setBounds(451, 183, 111, 23);
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
				CourseManage coursewindow=new CourseManage();
				coursewindow.setVisible(true);
				
				
				
			}
		});
		getContentPane().setLayout(null);
		getContentPane().add(button_2);
		
		JButton button_1 = new JButton("\u05DE\u05D1\u05D7\u05E0\u05D9\u05DD");
		button_1.setBounds(451, 291, 111, 23);
		button_1.setFont(new Font("David", Font.BOLD, 16));
		button_1.setBackground(UIManager.getColor("Button.background"));
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				TestManage testwindow=new TestManage();
				testwindow.setVisible(true);
				
			}
		});
		getContentPane().add(button_1);
		
		JButton button = new JButton("\u05D3\u05D5\u05D7\u05D5\u05EA");
		button.setFont(new Font("David", Font.PLAIN, 14));
		button.setBackground(UIManager.getColor("Button.background"));
		button.setBounds(451, 237, 111, 23);
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				ReportManage reportwindow=new ReportManage();
				reportwindow.setVisible(true);
			}
		});
		getContentPane().add(button);
		
		JButton btnNewButton = new JButton("\u05DE\u05D0\u05D2\u05E8 \u05DB\u05DC\u05D1\u05D9\u05DD");
		btnNewButton.setFont(new Font("David", Font.PLAIN, 14));
		btnNewButton.setBounds(451, 125, 111, 23);
		btnNewButton.setBackground(UIManager.getColor("Button.background"));
		getContentPane().add(btnNewButton);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				setVisible(false);
				DogManage dogwindow=new DogManage();
				dogwindow.setVisible(true);
				
			}
		});
	
		
		getContentPane().setLayout(null);
		
		JPanel panel = new JPanel();
		panel.setBounds(10, 95, 431, 256);
		panel.setBorder(new LineBorder(new Color(0, 0, 0), 2));
		getContentPane().add(panel);
		panel.setLayout(null);
		
		JLabel label_1 = new JLabel("\u05EA\u05D5\u05E6\u05D0\u05D5\u05EA \u05D4\u05DE\u05D1\u05D7\u05E0\u05D9\u05DD \u05E9\u05DC "+ tests.get(0).getName());
		label_1.setHorizontalAlignment(SwingConstants.RIGHT);
		label_1.setFont(new Font("David", Font.PLAIN, 16));
		label_1.setBounds(108, 11, 198, 23);
		panel.add(label_1);
	
		
		
		table = new JTable(tests.size(),6);
		table.setFont(new Font("David", Font.PLAIN, 13));
		
		table.getColumnModel().getColumn(0).setPreferredWidth(84);
		table.getColumnModel().getColumn(5).setPreferredWidth(34);
		table.setBackground(SystemColor.menu);
		table.setBorder(new CompoundBorder());
		table.setBounds(217, 88, 184, 144);
		
		//panel.add(table);
		
		table_1 = new JTable();
		table_1.setModel(new DefaultTableModel(
			new Object[][] {
				{"\u05D7\u05D9\u05E4\u05D5\u05E9 \u05D5\u05D4\u05EA\u05DE\u05D3\u05D4", "\u05D9\u05E6\u05E8 \u05D5\u05D1\u05D9\u05D8\u05D7\u05D5\u05DF", "\u05E0\u05E9\u05D9\u05DB\u05D4", "\u05D0\u05D5\u05DE\u05E5", "\u05EA\u05E7\u05D9\u05E4\u05D4", "\u05D2\u05D9\u05DC"},
			},
			new String[] {
				"New column", "New column", "New column", "New column", "New column", "New column"
			}
		));
		table_1.getColumnModel().getColumn(0).setPreferredWidth(84);
		table_1.getColumnModel().getColumn(5).setPreferredWidth(34);
		table_1.setFont(new Font("David", Font.BOLD, 13));
		table_1.setBorder(new BevelBorder(BevelBorder.LOWERED, new Color(0, 0, 0), null, null, null));
		table_1.setBackground(SystemColor.menu);
		table_1.setBounds(10, 55, 418, 16);
		panel.add(table_1);
		
		ScrollPane scrollPane = new ScrollPane();
		scrollPane.setBounds(10, 77, 418, 169);
		panel.add(scrollPane);
		scrollPane.add(table);
		
		JButton button_3 = new JButton("\u05D9\u05E6\u05D9\u05D0\u05D4 \u05DE\u05D4\u05DE\u05E2\u05E8\u05DB\u05EA");
		button_3.setFont(new Font("David", Font.PLAIN, 14));
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		button_3.setBounds(10, 362, 128, 23);
		getContentPane().add(button_3);

		
		
		for(int i=0;i<tests.size();i++)
		{
			
				table.setValueAt(tests.get(i).getAge(),i,5);
				table.setValueAt(tests.get(i).getEnterprise(),i,4);
				table.setValueAt(tests.get(i).getCourage(),i,3);
				table.setValueAt(tests.get(i).getBite(),i,2);
				table.setValueAt(tests.get(i).getSecurity(),i,1);
				table.setValueAt(tests.get(i).getSearch(),i,0);


		}
		
		ImageIcon ic=new ImageIcon("C:/Project/IDF1/MiscFiles/okets.jpg");
		JLabel lblNewLabel_1 = new JLabel(new ImageIcon("C:/Project/IDF1/MiscFiles/Picture4.jpg"));
		lblNewLabel_1.setBounds(-13, -84, 612, 610);
		getContentPane().add(lblNewLabel_1);
		
		ImageIcon ic1=new ImageIcon("C:/Project/IDF1/MiscFiles/okets.jpg");
		JLabel lblNewLabel_2 = new JLabel(new ImageIcon("C:/Project/IDF1/MiscFiles/Picture4.jpg"));
		lblNewLabel_2.setBounds(0, 0, 431, 374);
		panel.add(lblNewLabel_2);
		
		
		

	}
}



